﻿using Prism.Ioc;
using Prism.Modularity;
using Prism.Unity;
using Quartz;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using ZYing.QPanel.Views;

namespace ZYing.QPanel.Demo
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {
        protected override Window CreateShell()
        {
            return this.Container.Resolve<QPanel.Views.QPanelWindows>();
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterSingleton<Quartz.IScheduler>(() => SchedulerFactory.Create().GetAwaiter().GetResult());
        }


        protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
        {
            moduleCatalog.AddModule<QPanelModule>();
        }
        protected override async void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);
            var scheduler = this.Container.Resolve<IScheduler>();
            if (!scheduler.IsShutdown) await scheduler.Shutdown();
        }
    }
}
